<?php
/**
 * Created by IntelliJ IDEA.
 * User: 34984
 * Date: 2017/3/26
 * Time: 15:40
 */
//参考UPDATE ComputerBuy SET `Mortgage` = '是', `Buy` = 'Yes' WHERE id = '39'
$id  = $_GET['id'];
$age       = $_GET['age'];
$sex       = $_GET['sex'];
$region       = $_GET['region'];
$income       = $_GET['income'];
$married       = $_GET['married'];
$car       = $_GET['car'];
$mortgage       = $_GET['mortgage'];
$buy       = $_GET['buy'];


//DB config,DO NOT USE DEFINE,$result always callback 1
$DB_HOST = '182.254.219.244:3306';
$DB_USER = 'mldb';
$DB_PASS = 'mldbtest';
$DB_DATABASENAME = 'mldb';
$DB_TABLENAME = 'ComputerBuy';
//mysql_connect
$conn = mysql_connect($DB_HOST, $DB_USER, $DB_PASS) or die("connect failed" . mysql_error());
mysql_select_db($DB_DATABASENAME, $conn);

//Update row in db
$sql = sprintf("UPDATE %s SET Age="."'%s',"."Sex="."'%s',"."Region="."'%s',"."Income="."'%s',"."Married="."'%s',"."Car="."'%s',"."Mortgage ="."'%s',"."Buy="."'%s'"." WHERE id="."'%s'", $DB_TABLENAME, $age,$sex,$region,$income,$married,$car,$mortgage,$buy,$id);
/*UPDATE `mldb`.`student` SET `major` = '计算机' WHERE `student`.`sno` = '20100001'*/
//echo $sql;
$result = mysql_query($sql, $conn);
mysql_close($conn);
if ($result)
    echo "t";
else
    echo "f";
?>